import request from '@/utils/request'

// 查询库存信息列表
export function listInventory(query) {
  return request({
    url: '/inventory/inventory/list',
    method: 'get',
    params: query
  })
}

// 查询库存信息详细
export function getInventory(inventoryId) {
  return request({
    url: '/inventory/inventory/' + inventoryId,
    method: 'get'
  })
}

// 新增库存信息
export function addInventory(data) {
  return request({
    url: '/inventory/inventory',
    method: 'post',
    data: data
  })
}

// 修改库存信息
export function updateInventory(data) {
  return request({
    url: '/inventory/inventory',
    method: 'put',
    data: data
  })
}

// 删除库存信息
export function delInventory(inventoryId) {
  return request({
    url: '/inventory/inventory/' + inventoryId,
    method: 'delete'
  })
}

// 导出库存信息
export function exportInventory(query) {
  return request({
    url: '/inventory/inventory/export',
    method: 'post',
    params: query
  })
}

// 根据仓库ID和物料ID查询库存
export function getByWarehouseAndMaterial(warehouseId, materialId, batchCode) {
  return request({
    url: '/inventory/inventory/getByWarehouseAndMaterial',
    method: 'get',
    params: {
      warehouseId: warehouseId,
      materialId: materialId,
      batchCode: batchCode
    }
  })
}

// 根据物料编码查询库存列表
export function listByMaterialCode(materialCode) {
  return request({
    url: '/inventory/inventory/listByMaterialCode/' + materialCode,
    method: 'get'
  })
}

// 根据仓库编码查询库存列表
export function listByWarehouseCode(warehouseCode) {
  return request({
    url: '/inventory/inventory/listByWarehouseCode/' + warehouseCode,
    method: 'get'
  })
}